// Learn cc.Class:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        pauseButton: {
            default: null,
            type: cc.Button
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad() {
        this.ispause = 1;//用来记录鼠标点击次数
    },

    start() {

    },

    onclickbutton() {
        if (this.ispause % 2 != 0) {
            var self = this;

            //鼠标按下时事件
            self.pauseButton.node.on(cc.Node.EventType.TOUCH_START, function (event) {
                cc.director.pause();//暂停场景
                //cc.director.isPause();
                
            });
            // self.pauseButton.node.on(cc.Node.EventType.TOUCH_END , function (event) {
            //     cc.director.resume();
            // });
        }
        this.ispause = this.ispause++;
    },

    downclickbutton() {
        if (this.ispause % 2 == 0) {
            var self = this;
            self.pauseButton.node.on(cc.Node.EventType.TOUCH_START, function (event) {
                cc.director.resume();//继续播放场景
            });
        }
        this.ispause++;
    }

    // update (dt) {},
});
